package com.tuxing.draa_data.pojo.center;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;

import com.tuxing.draa_data.common.DraaContent;
import com.tuxing.draa_data.en.OrderLevelEnum;
import com.tuxing.draa_data.pojo.DraaTemporaryBook;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 *
 * </p>
 *
 * @author yuanshihang
 * @since 2021-12-06
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("new_dc_package")
public class NewDcPackage implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 包id
     */
    @TableId(value = "PACKAGE_ID", type = IdType.ASSIGN_ID)
    private Long packageId;

    /**
     * 所属库id
     */
    @TableField("COLLECTION_ID")
    private Long collectionId;

    /**
     * 电子资源包名称
     */
    @TableField("PACKAGE_NAME")
    private String packageName;

    /**
     * 订购层级  1全库订购 2子库订购 3单本订购 4单刊订购
     */
    @TableField("ORDER_LEVEL")
    private Integer orderLevel;

    /**
     * 来源类型 1=DRAA订购包 其他的后续添加
     */
    @TableField("TYPE")
    private Integer type;

    /**
     * 创建人
     */
    @TableField("CREATE_BY")
    private Integer createBy;

    /**
     * 创建时间
     */
    @TableField("CREATE_DATE")
    private LocalDateTime createDate;

    /**
     * 更新人
     */
    @TableField("UPDATE_BY")
    private Integer updateBy;

    /**
     * 更新时间
     */
    @TableField("UPDATE_DATE")
    private LocalDateTime updateDate;

    /**
     * draa包ID
     */
    @TableField("SOURCE_PID")
    private String draaPid;

    public void create(Long collectionId, String packageOuId, String minimumUnit, String level, Integer type) {
        this.collectionId = collectionId;
        this.packageName = minimumUnit;
        OrderLevelEnum enumByName = OrderLevelEnum.getEnumByName(level);
        if (enumByName != null) {
            this.orderLevel = enumByName.getValue();
        }
        this.type = type;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
        this.draaPid = packageOuId;
    }
}
